import {alert} from "../../components/common/alert";

import {get, post} from "../../utils/req";

const empty = {total: 0, list: [], page: 1, size: 10}

export async function list(data) {
    try {
        return await post('/private/class_group/list', data) || empty;
    } catch (e) {
        alert(`获取班级信息失败：${e}`, 'error');
        return empty;
    }
}

export async function save(data) {
    try {
        return await post('/private/class_group/save', data);
    } catch (e) {
        alert(`保存班级信息失败：${e}`, 'error');
        return 0;
    }
}

export async function del(classGroupId) {
    try {
        await get(`/private/class_group/delete?id=${classGroupId}`);
        return true;
    } catch (e) {
        alert(`删除班级信息失败：${e}`, 'error');
        return false;
    }
}
